<!doctype html>
<html lang="en">
	<body>
		<head>
			<head>
				<meta http-equiv='Content-Type' content='Type=text/html; charset=utf-8'>
				<title>Ruby Library - TNRoR</title>
				<link rel="stylesheet" href="styles.css" type="text/css" media="screen" />
				<link href="SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css">
				<%= stylesheet_link_tag "styles", :media => "screen" %>
				<%= stylesheet_link_tag "SpryMenuBarHorizontal", :media => "screen" %>
				<%= javascript_include_tag "equalcolumns", "http://code.jquery.com/jquery-latest.js", "SpryMenuBar" %>
			<style>
								nav.pagination a {
					/*padding: 2px 5px 2px 5px;
					margin-right: 2px;
					border: 1px solid #2E7D8A;
					text-decoration: none; 
					color: #2E7D8A;*/
					background: url("feed-title-white.jpg") repeat-x scroll center top #EFEFEF;
					    border: 1px solid #CCCCCC;
					    border-radius: 3px 3px 3px 3px;
					    color: #000000;
					    display: inline-block;
					    margin: 0;
					    padding: 5px 8px;
					    text-decoration: none;
					}
					nav.pagination a:hover, div.pagination a:active {
					/*border:1px solid #2E7D8A;
					color: #fff;
					background-color: #2E7D8A;*/
					 background: none repeat scroll 0 0 #313428;
					    border: 1px solid #CCCCCC;
					    border-radius: 3px 3px 3px 3px;
					    color: #FFFFFF;
					    margin: 0;
					    padding: 5px 8px;
					    text-decoration: none;
					}
					nav.pagination span.current {
					 background: none repeat scroll 0 0 #313428;
					    border: 1px solid #CCCCCC;
					    border-radius: 3px 3px 3px 3px;
					    color: #FFFFFF;
					    margin: 0;
					    padding: 5px 8px;
					    text-decoration: none;
					}
					nav.pagination span.disabled {
					padding: 2px 5px 2px 5px;
					margin-right: 2px;
					border: 1px solid #f3f3f3;
					color: #ccc;
					}
					.pagination{
					    float:left;
					}
			</style>
			</head>
		</head>
		<header>
			<h1> <%= image_tag "header.png", :alt => "f", :width => "960", :height => "150" %> </h1>
		</header>
		<ul id="MenuBar1" class="MenuBarHorizontal">
			<li>
				<% if @user.id != nil%>
				<a href="/account/new" class="MenuBarItemSubmenu" >Trang Chủ</a>
				<% else %>
				<%= link_to 'Trang Chủ', login_path, :class=>'MenuBarItemSubmenu'%>
				<% end%>
			</li>
			<li>
				<a href="#" class="MenuBarItemSubmenu">Sách</a>
				<ul>
					<li >
						<a href="/newbooks/new" class="menustyle" >Sách mới</a>
					</li>
					<li>
						<a href="/hotbooks/new" class="menustyle" >Sách hay</a>
					</li>
					<li>
						<a href="/searchbooks/new" class="menustyle" >Tìm kiếm</a>
					</li>
				</ul>
			</li>
			<% if @user.id != nil%>
			<li>
				<a class="MenuBarItemSubmenu" href="#">Tài khoản</a>
				<ul>

					<li>
						<%= link_to 'Thông Tin', @user, :class=>'menustyle'%>
					</li>
					<li>
						<a href="/books_history/index" class="menustyle">Sách đã mượn</a>
					</li>
				</ul>
			</li>
			<% else %>
			<li>
				<a class="MenuBarItemSubmenu" href="/users/new">Tạo Tài khoản</a>
			</li>
			<% end%>
			<li>
				<a href="#" class="MenuBarItemSubmenu">Liên Hệ</a>
			</li>
		</ul>
		<br>
		<br>
		<div id="innercontent">
          <h2> Sách hay nhiều người xem </h2>
			<div class="login_form">
				<% if flash[:notice] %>
				<p id="notice">
					<%= notice %>
				</p>
				<% end %>
				<% if flash[:alert] %>
				<p id="notice">
					<%= flash[:alert] %>
				</p>
				<% end %>
			</div>

            <%= paginate @books %>
			<br/><br/>
			<table>
                <% for book in @books %>
				<tr>
					<td width = "130" height="170" valign="top"> <%= link_to image_tag(book.link, :width => 120, :height => 160), viewbooks_index_path(:book_id => book) %> <td valign="top"> Tên Sách: <%= book.name %>
					<br>
					Danh Mục <%= book.category.name %>
					<br>
					Tách giả <%= book.author %>
					<br>
					Thời điểm xuất bản: <%= book.created_at.strftime("%m-%d-%Y") %>
					<br>
                    Lượt xem: <%= book.view%>
					<br>
					</td>
					<td valign="top"> <%= button_to 'Xem chi tiết', viewbooks_show_path(:book_id => book), :class=>'buttonstyle'%> </td>
					<% if @user.id != nil%>
					<td valign="top"> <%= button_to 'Mượn sách này', account_create_path(:book_id => book, :path => request.url), :method => :post, :class=>'buttonstyle' %> </td>
					<% end%>
				</tr>
				<% end %>
			</table>
		</div>

		<aside>
			<section>
				<header>
					<h3>Tìm kiếm sách</h3>
				</header>
				<%= form_tag searchbooks_new_path(:search_option => 0), :method => :get do %>
				<p>
					<%= text_field_tag :search, params[:search], :size =>25 %>
					<input type="submit" name="Searchbtn" id="Searchbtn" value="Tìm" class="buttonstyle">
				</p>
				<% end %>
			</section>
			<section>
				<% if @user.id == nil%>
				<header>
					<h3>Đăng Nhập</h3>
				</header>
				<%= form_tag login_url do %>
				<table width="260" border="0">
					<tr>
						<td width="71">Tài Khoản</td>
						<td width="179"><%= text_field_tag :name, params[:name],:size=>25 %></td>
					</tr>
					<tr>
						<td>Mật Khẩu</td>
						<td><%= password_field_tag :password, params[:password],:size=>25 %></td>
					</tr>
					<tr>
						<td colspan="2"> <%= submit_tag "Đăng Nhập", :name => "login",:class=>'buttonstyle' %>
						<%= submit_tag "Đăng Kí", :name =>  'signup', :class=>'buttonstyle' %></td>
					</tr>
					<tr>
						<td colspan="2"><%= link_to 'Quên Mật Khẩu?', new_forgotpas_path%></td>
					</tr>
				</table>
				<% end %>
				<% else%>
				<header>
					<h3>Xin chào, <%= @user.name%></h3>
				</header>
				<%= button_to 'Logout', logout_path, :method => :delete, :class=>'buttonstyle'%></td>
				<% end%>
			</section>
			<section>
				<header>
					<h3>Danh mục</h3>
				</header>
				<p>
					<% @categories.each do |item| %>
					- <%= link_to item.name + ' (' + item.books.size.to_s + ')', {:controller => "viewbookbycategory", :action => "new", :cat_id => item.id}%>
					<br>
					<% end %>
				</p>
			</section>
		</aside>
		<footer>
			<br />
			<p class="fcentered">
				------ Ruby Library - TNROR 2012 ------
				<br/>
			</p>
		</footer>
		<script type="text/javascript">
			var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {
				imgDown : "SpryAssets/SpryMenuBarDownHover.gif",
				imgRight : "SpryAssets/SpryMenuBarRightHover.gif"
			});
		</script>
	</body>
</html>

